-- 创建存储过程（统计订单总额）
CREATE PROCEDURE sp_get_order_total
    @customer_id INT,
    @total_amount DECIMAL(18,2) OUTPUT
AS
BEGIN
    SELECT @total_amount = SUM(TotalAmount)
    FROM Orders
    WHERE CustomerID = @customer_id
END
-- 调用存储过程
DECLARE @result DECIMAL(18,2)
EXEC sp_get_order_total 123, @result OUTPUT
PRINT '订单总额：' + CAST(@result AS VARCHAR)
